services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        bind:
            $dropboxKey: "%dropbox_key%"
            $dropboxSecret: "%dropbox_secret%"

    Mtt\BlogBundle\:
        resource: '../../*'
        exclude: '../../{Entity,Model,Event,OAuth2,Utils,Service/IpInfo/LocationInfo.php,Doctrine/DBAL,DTO,Form}'

    Mtt\BlogBundle\Entity\Repository\:
        resource: '../../Entity/Repository'
        tags: ['doctrine.repository_service']

    Mtt\BlogBundle\Controller\:
        resource: '../../Controller'
        tags: ['controller.service_arguments']

    _instanceof:
        Mtt\BlogBundle\Cron\DailyCronServiceInterface:
            tags:
                - { name: cron-daily }
        Mtt\BlogBundle\Cron\HourlyCronServiceInterface:
            tags:
                - { name: cron-hourly }
        Xelbot\Telegram\Command\TelegramCommandInterface:
            tags:
                - { name: telegram-command }

    Mtt\BlogBundle\Controller\DefaultController:
        arguments:
            $kernelEnv: '%kernel.environment%'
            $cdnUrl: '%cdn_url%'
            $blogUrl: '%frontend_site%'

    Mtt\BlogBundle\Controller\TelegramController:
        arguments:
            $secretToken: '%telegram_webhook_token%'

    Mtt\BlogBundle\Controller\GitRepoController:
        arguments:
            $secretToken: '%gitrepo_webhook_token%'

    Mtt\BlogBundle\EventListener\JsonBodyListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 10 }

    Mtt\BlogBundle\EventListener\Doctrine\ArticleUpdatedAtListener:
        tags:
            - { name: doctrine.event_listener, event: preUpdate }

    Mtt\BlogBundle\EventListener\Doctrine\IgnoreTablesListener:
        tags:
            - {name: doctrine.event_listener, event: postGenerateSchema }

    Mtt\BlogBundle\EventListener\Doctrine\MediaFilePictureListener:
        tags:
            - { name: doctrine.event_listener, event: preUpdate }

    Mtt\BlogBundle\Service\IpInfo\IpInfoDbClient:
        arguments:
            $key: "%ipinfodb_key%"

    Mtt\BlogBundle\Service\IpInfo\IpInfoClientInterface: '@Mtt\BlogBundle\Service\IpInfo\IpInfoDbClient'

    Mtt\BlogBundle\EventListener\CommentatorCheckListener:
        tags:
            - { name: kernel.event_listener, event: mtt_blog.reply_comment, method: onReply }

    Mtt\BlogBundle\EventListener\CommentGeolocationListener:
        tags:
            - { name: kernel.event_listener, event: mtt_blog.reply_comment, method: onReply }

    Mtt\BlogBundle\EventListener\NewCommentEmailListener:
        tags:
            - { name: kernel.event_listener, event: mtt_blog.reply_comment, method: onReply }

    Mtt\BlogBundle\EventListener\ReplyCommentListener:
        tags:
            - { name: kernel.event_listener, event: mtt_blog.reply_comment, method: onReply }

    Mtt\BlogBundle\EventListener\PygmentsCodeUpdateListener:
        tags:
            - { name: kernel.event_listener, event: mtt_blog.code_updated, method: onUpdate }

    Mtt\BlogBundle\Cron\Daily\DatabaseBackup:
        arguments:
            - "%database_host%"
            - "%database_name%"
            - "%database_user%"
            - "%database_password%"

    Mtt\BlogBundle\Cron\Hourly\TelegramUpdates:
        arguments:
            $adminId: "%telegram_admin_id%"

    Mtt\BlogBundle\Service\ImageManager:
        arguments:
            $cdn: "%cdn_url%"

    Mtt\BlogBundle\Service\Mailer:
        arguments:
            $emailFrom: "%mailer_user%"

    Mtt\BlogBundle\Service\SystemParametersStorage:
        arguments:
            $secret: "%secret%"

    mtt_blog.text_processor:
        alias: Mtt\BlogBundle\Service\TextProcessor
        public: true

    mtt_blog.telegram_logger:
        class: Monolog\Logger
        factory: [ "Mtt\\BlogBundle\\Telegram\\TelegramLoggerFactory", createLogger ]
        arguments: [ "%kernel.logs_dir%" ]

    mtt_blog.telegram_bot:
        class: Xelbot\Telegram\Robot
        arguments:
            - "%telegram_token%"
            - "%telegram_bot%"
            - "%telegram_admin_id%"
        calls:
            - [ setLogger, [ "@mtt_blog.telegram_logger" ]]
            - [ setUpdatesManager, [ '@Mtt\BlogBundle\Telegram\UpdatesManager' ]]

    Mtt\BlogBundle\ArgumentResolver\PostValueResolver:
        tags:
            - { name: controller.argument_value_resolver, priority: 50 }

    Xelbot\Telegram\Robot: '@mtt_blog.telegram_bot'
